<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Poster Thailand</title>
<link href="<?php echo  WEB_URL;?>/styles/style.css" rel="stylesheet" />
<link href="<?php echo  WEB_URL;?>/styles/ads.css" rel="stylesheet" />
<link type="text/css" href="<?php echo  WEB_URL;?>/styles/ui-lightness/jquery-ui-1.8rc2.custom.css" rel="stylesheet" />

<!-- StyleSheet Plugin-->
<link type="text/css" href="<?php echo  WEB_URL;?>/styles/jqtransform.css" rel="stylesheet" />
<link type="text/css" href="<?php echo  WEB_URL;?>/styles/jquery.checkbox.css" rel="stylesheet" />
<link type="text/css" href="<?php echo  WEB_URL;?>/styles/vtip.css" rel="stylesheet" />
<link rel="stylesheet" href="<?php echo  WEB_URL;?>/styles/validationEngine.jquery.css" type="text/css" media="screen"/>

<script type="text/javascript" src="<?php echo  WEB_URL;?>/scripts/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<?php echo  WEB_URL;?>/scripts/jquery/jquery-ui-1.8rc2.custom.min.js"></script>

<!-- Script Plugin -->
<script type="text/javascript" src="<?php echo  WEB_URL;?>/scripts/jquery/jquery.jqtransform.js"></script>
<script type="text/javascript" src="<?php echo  WEB_URL;?>/scripts/jquery/jquery.checkbox.min.js"></script>
<script type="text/javascript" src="<?php echo  WEB_URL;?>/scripts/jquery/vtip.js"></script>
<script src="<?php echo  WEB_URL;?>/scripts/jquery/jquery.validationEngine-th.js" type="text/javascript"></script>
<script src="<?php echo  WEB_URL;?>/scripts/jquery/jquery.validationEngine.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo  WEB_URL;?>/scripts/jquery/tab.js"></script>

<script type="text/javascript">
$(function(){

	$('form').jqTransform({imgPath:'<?php echo  WEB_URL;?>/styles/images/jqtransform/'});

 	//$('input:checkbox:not([safari])').checkbox();
  	//$('input:radio').checkbox();
	
	$('#signup_form').validationEngine();
	
	$('#move_up',this).click(function(){
		var move_pid = $(this).attr('pid');
		$.post('../query.php', { move_up:true, pid:move_pid }, function(msg){
			msg.status == 1 ? alert('เลื่อนลำดับประกาศสำเร็จแล้ว') : alert('คุณเลื่อนลำดับประกาศได้วันละครั้งค่ะ');
			location.reload();
		},'json');
		return false;
	});
	
});
</script>

</head>

<body>
	<div class="page">
    
    	<?php require_once('../header.php');?>
        
        <div class="content">
        	<div id="wrap_top">
            	<div id="wrap_top_left">
                	<!--<div id="wrap_ads">                	 
                        <div id="wrap_728x90"></div>
                	</div>-->
                 	<?php 
						$sql = "SELECT
								  `products`.*, `products_img`.`img1`, `category`.`cat_name`,
								  `subcat`.`sub_name`
								FROM
								  `products` INNER JOIN
								  `products_img` ON `products`.`pid` = `products_img`.`pid` INNER JOIN
								  `category` ON `products`.`cat_id` = `category`.`cat_id` INNER JOIN
								  `subcat` ON `subcat`.`cat_id` = `category`.`cat_id`
								WHERE
								  `products`.`poster` = '".$_SESSION['usr']."'
								GROUP BY
								  `products`.`pid`
								ORDER BY
								  `products`.`p_change_place` DESC, `products`.`p_create` DESC
								LIMIT 0, 10";
                    	$get_post = $db->select_query($sql);
						$cout_post = $db->rows($get_post);
                    ?>
                 	<div class="ui-corner-all">
                        <div class="top">   
                            <div class="left"></div>   
                            <div class="right"></div>
                            <div class="center">
                              <h3>10 ประกาศล่าสุด</h3>  
                            </div>
                        </div>
                        <div class="middle">
                        <a class="large button blue" href="<?php echo WEB_URL;?>/products/?m=post&p=select_cat">ลงประกาศฟรี!</a> <a class="large button blue" href="?m=profile&p=my_post">ดูประกาศทั้งหมด</a>
                        <div id="post" style="margin-top: 10px;">
                        
                        <table id="list" width="693" border="0" cellspacing="1" cellpadding="1">
                            <thead>
                              <tr>                            	
                              	<td class="left"><div align="center">รูปภาพ</div></td>
                                <td class="right"><div align="center">รายการประกาศ</div></td>    
                                <td width="64"><div align="center">แก้ไข</div></td>     
                                <td width="119"><div align="center">เลื่อนประกาศ</div></td>                       
                              </tr>
                            </thead>
                            <tbody>
                               <?php 
								if($cout_post>0){
                                while($show_post = $db->fetch($get_post)){
                                ?>
	                                <tr>
	                                    <td width="47"><div id="post_img"><img src="<?php echo IMG_PATH.$show_post['img1'];?>" /></div></td>
	                                    <td width="500">
	                                        <div id="post_title" style="width: 475px;">
	                                            <div id="post_header"><a href="<?php echo WEB_URL.'/products/?m=products&p=product_detail&pid='.$show_post['pid'];?>"><?php echo $show_post['p_title'];?></a> <span id="price">฿ <?php ($show_post['p_sure_price'] != 0)? print $show_post['p_sure_price'].' บาท': print $show_post['p_price'];?></span></div>
	                                            <span id="post_cat">Category :  <a href="<?php echo WEB_URL.'/products/?m=categories&p=categories&cid='.$show_post['cat_id'].'&c='.$show_post['cat_name'];?>"><?php echo $show_post['cat_name'];?></a></span> | <span id="post_dat"> Date Poste : <?php echo $show_post['p_create'];?></span>            
	                                        </div> 
	                                    </td>                               
	                                    <td><a href="<?php echo WEB_URL;?>/products/?m=post&p=edit_post&pid=<?php echo $show_post['pid'];?>&c=<?php echo $show_post['cat_name'];?>&sc=<?php echo $show_post['sub_name'];?>" id="edit_post" pid="<?php echo $show_post['pid'];?>"><img src="../styles/images/notepad.png" width="64" /></a></td>
	                                    <td><a href="#" id="move_up" pid="<?php echo $show_post['pid'];?>"><img src="../styles/images/up.png" width="64" align="middle" /></a></td>
	                               	</tr>	
                                <?php 
								}
                                }else{
								?>
									<tr>
                                        <td colspan="5"><div style="color: #0369C0; font-size: 18px; font-weight: bold; padding: 10px; text-align: center;">ยังไม่มีประกาศ</div></td>
                                  	</tr>
								<?php
								}
                                ?>
                            </tbody>
                        </table>
                      
                        </div>
                    
                      </div>
                    
                        <div class="bottom">
                            <div class="left"></div>
                            <div class="right"></div>
                            <div class="center"></div>
                        </div>
                        
                    </div>	                     
                                
                   	<div class="ui-corner-all">
                    <?php
						$inv_sql = 'SELECT * FROM order_ads';
						$q = $db->select_query($inv_sql);
						$count = $db->rows($q);
					?>
                        <div class="top">   
                            <div class="left"></div>   
                            <div class="right"></div>
                            <div class="center">
                              <h3><?php echo $count;?> รายการชำระเงิน</h3>  
                            </div>
                        </div>
                        <div class="middle">                        
                        <table id="list" width="730" border="0" cellspacing="1" cellpadding="1">
                            <thead>
                              <tr>                            	
                              	<td width="32"><div align="center">Invoice</div></td>
                                <td width="64"><div align="center">วันที่ลงประกาศ</div></td>
                                <td width="32"><div align="center">ลงโฆษณา</div></td> 
                              	<td width="64"><div align="center">สิ้นสุดประกาศ</div></td>
                                <td width="64"><div align="center">รูปแบบโฆษณา</div></td>     
                                <td width="32"><div align="center">ราคารวม</div></td>                       
                                <td width="64"><div align="center">สถานะ</div></td>                       
                                <td width="64"><div align="center">ตำแหน่ง</div></td>                       
                              </tr>
                            </thead>
                            <tbody>
                            <?php
                            while($order = $db->fetch($q)){
							$ads_code = explode('#',$order['ads_id']);
							if($order['type']=='banner'){
								$advertise = mysql_query('SELECT banner_expire,period,position_id FROM banners WHERE banner_id="'.$ads_code[0].'"');
								$expire = mysql_fetch_assoc($advertise);
								$ads_axpire = $expire['banner_expire'];
								$period	= $expire['period'];
								$pos = $expire['position_id'];
							}else{
								$advertise = mysql_query('SELECT ads_expire,ads_period,position_id FROM advertise WHERE id="'.$ads_code[0].'"');
								$expire = mysql_fetch_assoc($advertise);
								$ads_axpire = $expire['ads_expire'];
								$period	= $expire['ads_period'];
								$pos = $expire['position_id'];
							}
							$getpos = mysql_query('SELECT position_name FROM positions WHERE id='.$pos);
							$position = mysql_fetch_assoc($getpos);
							?>
                            <tr align="center">
                            	<td><strong><?php echo $order['invoice'];?></strong></td>
                                <td><strong><?php echo ThaiTimeConvert($order['created_at'],0,0);?></strong></td>
                                <td><strong><?php echo $period.' เดือน';?></strong></td>
                                <td><strong><?php echo ThaiTimeConvert($ads_axpire,0,0);?></strong></td>
                                <td><strong><?php ($order['type']=='banner')?print'แบนเนอร์':print'ปักหมุด';?></strong></td>
                                <td align="left"><strong style="color:red;"><?php echo $order['total'].' ฿';?></strong></td>
                                <td>
                                	<?php ($order['status']==1)?print '<strong style="color:orange;">กำลังตรวจสอบ</strong>': ($order['status']==2 ? print '<strong style="color:green;">ชำระค่าแล้ว</strong>': ($order['status']==3 ? print 'หมดอายุ' : print '<strong style="color:red;">ยังไม่ชำระ</strong>'));?>
                                </td>
                                
                                <td><strong><?php echo $position['position_name'];?></strong></td>
                              </tr>
                            <?
							}
							if(empty($count)){
							?>
                             <tr align="center">
                            	<td colspan="8">
                                	<div style="color: #0369C0; font-size: 18px; font-weight: bold; padding: 10px; text-align: center;">ยังไม่มีรายการที่ต้องชำระ</div>
                                </td>
                              </tr>
                            <?php	
							}
							?>
                            </tbody>
                       	</table>
                        </div>
                        <div class="bottom">
                            <div class="left"></div>
                            <div class="right"></div>
                            <div class="center"></div>
                        </div>    
                  	</div>                            
              	</div>
                
              	<?php require('user_menu.php');?>
                
            </div>
            
            
        </div>
        
        <?php require_once('../footer.php');?>
        
    </div>
</body>
</html>